
<h1><span class="yiyi-st" id="yiyi-12">numpy.geterr</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.geterr.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.geterr.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="function">
<dt id="numpy.geterr"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.</code><code class="descname">geterr</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="http://github.com/numpy/numpy/blob/v1.11.3/numpy/core/numeric.py#L2676-L2724"><span class="viewcode-link">[source]</span></a></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">获取当前处理浮点错误的方法。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-15">返回：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-16"><strong>res</strong>：dict</span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-17">具有键“divide”，“over”，“under”和“invalid”的字典，其值来自字符串“ignore”，“print”，“log”，“warn”，“raise” “。</span><span class="yiyi-st" id="yiyi-18">键表示可能的浮点异常，值定义了如何处理这些异常。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-19">也可以看看</span></p>
<p class="last"><span class="yiyi-st" id="yiyi-20"><a class="reference internal" href="numpy.geterrcall.html#numpy.geterrcall" title="numpy.geterrcall"><code class="xref py py-obj docutils literal"><span class="pre">geterrcall</span></code></a>，<a class="reference internal" href="numpy.seterr.html#numpy.seterr" title="numpy.seterr"><code class="xref py py-obj docutils literal"><span class="pre">seterr</span></code></a>，<a class="reference internal" href="numpy.seterrcall.html#numpy.seterrcall" title="numpy.seterrcall"><code class="xref py py-obj docutils literal"><span class="pre">seterrcall</span></code></a></span></p>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-21">笔记</span></p>
<p><span class="yiyi-st" id="yiyi-22">有关浮点异常和处理选项类型的完整文档，请参见<a class="reference internal" href="numpy.seterr.html#numpy.seterr" title="numpy.seterr"><code class="xref py py-obj docutils literal"><span class="pre">seterr</span></code></a>。</span></p>
<p class="rubric"><span class="yiyi-st" id="yiyi-23">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">geterr</span><span class="p">()</span>
<span class="go">{&apos;over&apos;: &apos;warn&apos;, &apos;divide&apos;: &apos;warn&apos;, &apos;invalid&apos;: &apos;warn&apos;,</span>
<span class="go">&apos;under&apos;: &apos;ignore&apos;}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mf">3.</span><span class="p">)</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mf">3.</span><span class="p">)</span>
<span class="go">array([ NaN,   1.,   1.])</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">oldsettings</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">seterr</span><span class="p">(</span><span class="nb">all</span><span class="o">=</span><span class="s1">&apos;warn&apos;</span><span class="p">,</span> <span class="n">over</span><span class="o">=</span><span class="s1">&apos;raise&apos;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">geterr</span><span class="p">()</span>
<span class="go">{&apos;over&apos;: &apos;raise&apos;, &apos;divide&apos;: &apos;warn&apos;, &apos;invalid&apos;: &apos;warn&apos;, &apos;under&apos;: &apos;warn&apos;}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mf">3.</span><span class="p">)</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mf">3.</span><span class="p">)</span>
<span class="go">__main__:1: RuntimeWarning: invalid value encountered in divide</span>
<span class="go">array([ NaN,   1.,   1.])</span>
</pre></div>
</div>
</dd></dl>
